package com.me.springcloud.hystrix;

import com.netflix.hystrix.HystrixCommand;
import com.netflix.hystrix.HystrixCommandGroupKey;
import com.netflix.hystrix.HystrixCommandKey;
import com.netflix.hystrix.HystrixThreadPoolKey;

public class CommandHelloWorld2 extends HystrixCommand<String> {

	private final String name;

	private static final Setter cachedSetter = Setter.withGroupKey(HystrixCommandGroupKey.Factory.asKey("ExampleGroup"))
			.andCommandKey(HystrixCommandKey.Factory.asKey("HelloWorld")).andThreadPoolKey(HystrixThreadPoolKey.Factory.asKey("HelloWorldPool"));

	public CommandHelloWorld2(String name) {
		super(cachedSetter);
		this.name = name;
	}

	@Override
	protected String run() {
		throw new RuntimeException("this command always fails");
//		return "Hello " + name + "!";
	}

	@Override
	protected String getFallback() {
		// TODO Auto-generated method stub
		return "Hello Fallback";
	}

}